package com.qxf.consumer.controller;


import com.qxf.common.entities.CommonResult;
import com.qxf.common.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author qxf101
 */
@RestController
@Slf4j
public class ConsumerController {
    private static final String URL = "http://PRODUCE/";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping(value = "/create")
    public CommonResult<Payment> create(Payment payment) {
        return restTemplate.postForObject(URL + "create", payment, CommonResult.class);
    }

    @GetMapping(value = "/getPaymentById/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        return restTemplate.getForObject(URL + "getPaymentById/" + id, CommonResult.class);
    }
}
